package join;

/**
 * Created by zhengjiasen on 2018/3/3.
 */

import join.util.GetTaggedFileSplit;
import join.util.StringArrayUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;


import java.io.IOException;


/**
 * @author zhengjiasen
 * @date 2018/3/3
 * <p>
 * 文件格式为<号码，1>或者<号码 >.
 */
public class TarDataFileMapper extends Mapper<Object, Text, Text, Text> {

    /**
     * 定义一个字段，用于存放Map输出的value
     */
    private Text text = new Text();
    private Text outKey = new Text();

    @Override
    public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

        String[] split = value.toString().split(",");
        outKey.set(split[0]);
        text.set("B".concat(new StringArrayUtil(split).slice(1)));
        context.write(outKey, text);

    }

}
